home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / JAVA Utilities / JProxy 1.1.0 / customers / buy-oem-upgrade.jsp < prev    next >
Encoding:
Text File  |  2003-04-29  |  7.4 KB  |  189 lines

  1. <%@ page language="java" import="
  2.     java.util.*,
  3.     com.jproxy.site.mbeans.JMXInvocator,
  4.     com.jproxy.site.mbeans.config.*,
  5.     com.jproxy.site.ejbeans.interfaces.ISaleFormula,
  6.     com.jproxy.site.ejbeans.interfaces.IProduct,
  7.     com.jproxy.site.*"
  8. %>
  9.  
  10. <jsp:useBean id="buycustomers" scope="request" class="com.jproxy.site.customers.Buy"/>
  11. <%
  12. buycustomers.request(pageContext);
  13. buycustomers.ses.setNewHit(pageContext, "hits", "OEM Buy Page", null);
  14. %>
  15.  
  16. <%
  17. int licenses = buycustomers.purchasedLicenses;
  18. int purchasedLicenses = 0;
  19. String productName = "";
  20.  
  21. String productID = buycustomers.getParameter("productid").trim();
  22. if(buycustomers.getParameter("licenses").trim().length()>0)
  23.     licenses = new Integer(buycustomers.getParameter("licenses")).intValue();
  24. if(buycustomers.getParameter("purchased-licenses").trim().length()>0)
  25.     purchasedLicenses = new Integer(buycustomers.getParameter("purchased-licenses")).intValue();
  26.  
  27.  
  28. // find out the number of licenses requested
  29. if (licenses <= 0)
  30.     licenses = 1;
  31.  
  32. if(productID.length()>0)
  33.     productName = buycustomers.product.getProductName();
  34. else
  35. {
  36. %>
  37.     <span class="h9Verdana">Failed to obtain Product Id!
  38.     Please report this error to <a class="h8VerdanaBold" href="mailto:postmaster@jproxy.com">postmaster@jproxy.com</a></span>
  39. <%
  40.     return;
  41. }
  42.  
  43. String customerName = buycustomers.customer.getCustomerName();
  44. String host = "http://"+request.getServerName()+":"+request.getServerPort();
  45.  
  46. int invoice = 0;
  47. int customerId = 0;
  48. boolean isDisabled = false;
  49. ISaleFormula formula = (ISaleFormula)buycustomers.formulas.elementAt(0);
  50.  
  51. int firstLicensePrice = formula.getFirstLicense();
  52. int additionalLicensePrice = formula.getAdditionalLicense();
  53. if(purchasedLicenses>0)
  54.     firstLicensePrice = additionalLicensePrice;
  55.  
  56. // calculate the TOTAL AMOUNT based on the number of licenses and the pricing model
  57. double lic_cost = firstLicensePrice * buycustomers.formula.getDiscount();
  58. lic_cost += (licenses-1) * additionalLicensePrice * buycustomers.formula.getDiscount();
  59. lic_cost = lic_cost*buycustomers.formula.getUpgrade();
  60. //double sup_cost = lic_cost * buycustomers.formula.getSupport() * support_licenses;
  61. double sup_cost = lic_cost * buycustomers.formula.getSupport();
  62.  
  63. if(request.getParameter("submit_recalculate")!=null)
  64. {
  65. }
  66. if(request.getParameter("submit_purchase")!=null && request.getParameter("error")==null)
  67. {
  68. %>
  69.     <jsp:forward page="purchase.jsp"/>
  70. <%
  71. }
  72. %>
  73.   <!-- HEADER -->
  74.   <jsp:include page="header.jsp" flush="true">
  75.     <jsp:param name="name" value="ePortal - Upgrade Licenses and Technical Support"/>
  76.     <jsp:param name="pageId" value="buy"/>
  77.   </jsp:include>
  78.  
  79. <!-- MAIN PANEL -->
  80. <%
  81. ConfigMBean mbean = (ConfigMBean)JMXInvocator.getMBean("JProxy:service=JProxyConfigMBean", ConfigMBean.class);
  82. //String productName = mbean.get("com.jproxy.proxy.name") + " " + mbean.get("com.jproxy.proxy.version");
  83. String invoiceStr = mbean.get("com.jproxy.commerce.invoice");
  84. try{
  85.     invoice = Integer.parseInt(invoiceStr);
  86. }
  87. catch(Exception e)
  88. {
  89.     invoice = 15;
  90. }
  91. %>
  92.  
  93.   <br>
  94.   You're about to purchase licenses for your <span class="h9VerdanaBold"><%=customerName%></span> customer.
  95.   <p>
  96.   Once the payment is made the new total of purchased licenses will be changed to include newly purchased licenses.
  97.   <p>
  98.   Please enter the number of licenses you would like to purchase and click <b>Recalcualte</b> to get the updated price
  99.   <p>
  100.   <br>
  101.     <table class="h9Verdana" cellpadding="5" width="100%" border="0">
  102.   <!-- Prolog -->
  103.           <tr>
  104.            <td>
  105.                   <table class="h9Verdana" border="0" bgcolor="9c9cff" cellpadding="1" cellspacing="0">
  106.                    <tr><td>
  107.                      <%=productName%>
  108.                    </td></tr>
  109.                    <tr><td>
  110.                        <form method="get" action="buy.jsp">
  111.                            <table class="h8Verdana" border="0" bgcolor="white" cellpadding="5" cellspacing="1" width="100%">
  112.                             <tr>
  113.                              <td align="left">
  114.                                     <br>
  115.                                     Quantity:
  116.                                     <input type="input" name="licenses" READONLY value="<%=licenses%>" size="3">
  117.                                     <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  118.                                      Licenses:
  119.                                      <input type="text" name="total" READONLY value="$<%=lic_cost%>" size="8">
  120.                                      Technical Support:
  121.                                      <input type="text" name="total" READONLY value="$<%=sup_cost%>" size="8">
  122.                                      Order Total:
  123.                                      <input type="text" name="total" READONLY value="$<%=(lic_cost + sup_cost)%>" size="8">
  124.                              </td>
  125.                             </tr>
  126.                             <tr>
  127.                              <td class="h8Verdana" align="right">
  128.                               <INPUT TYPE=SUBMIT NAME=submit_recalculate WIDTH="20" VALUE="Recalculate">
  129.                               <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  130.                               <INPUT TYPE=HIDDEN NAME="purchased-licenses" VALUE="<%=purchasedLicenses%>">
  131.                               <INPUT TYPE=HIDDEN NAME="is-upgrade" VALUE="true">
  132.                              </td>
  133.                             </tr>
  134.                           </table>
  135.                       </form>
  136.     <!-- begin separator -->
  137.                     </td></tr>
  138.                     <tr><td>
  139.     <!-- end separator -->
  140.                      <table class="h8Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="0" >
  141.                           <tr>
  142.                            <td align="left">
  143.                              When you're ready to proceed to a secure payment form
  144.                              please press the <b>Purchase</b> button
  145.                            </td>
  146.                            <td align="right">
  147.                              <br>
  148.         <%
  149.         String headerHTML = "<font size=30 color=#6331CE>JProxy</font>";
  150.             headerHTML += "<font size=10 color=#9C00FF>.com</font>";
  151.         String footerHTML = "<font size=2><em>Copyright 2001-2002, JProxy</em></font>";
  152.         String description = "productName : "+productName;
  153.             description += "<br>Customer Name : "+customerName;
  154.             description += "<br>Licenses # : "+licenses+" ($"+lic_cost+")";
  155.             description += "<br>Technical support : $"+sup_cost;
  156.         %>
  157.                              <FORM METHOD=POST ACTION="https://secure.authorize.net/gateway/transact.dll">
  158.                     <INPUT TYPE=HIDDEN NAME="number_of_licenses" VALUE="<%=licenses%>">
  159.                     <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  160.                     <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  161.                     <INPUT TYPE=HIDDEN NAME="parent-id" VALUE="<%=buycustomers.ses.getLogin().getID()%>">
  162.                     <INPUT TYPE=HIDDEN NAME="is-upgrade" VALUE="true">
  163.                     <INPUT TYPE=HIDDEN NAME="x_amount" VALUE="<%=(lic_cost + sup_cost)%>">
  164.                     <INPUT TYPE=HIDDEN NAME="x_Version" VALUE="3.0">
  165.                     <INPUT TYPE=HIDDEN NAME="x_Login" VALUE="jproxyllc">
  166.                     <INPUT TYPE=HIDDEN NAME="x_Show_Form" VALUE="PAYMENT_FORM">
  167.                     <INPUT TYPE=HIDDEN NAME="x_Cust_ID" VALUE="<%=customerId%>">
  168.                     <INPUT TYPE=HIDDEN NAME="x_Invoice_Num" VALUE="<%=invoice%>">
  169.                     <INPUT TYPE=HIDDEN NAME="x_Description" VALUE="<%=description%>">
  170.                     <!-- INPUT TYPE=HIDDEN NAME="x_Logo_URL" VALUE="http://jproxy.com/main/resources/jproxy.gif" -->
  171.                     <INPUT TYPE=HIDDEN NAME="x_Header_HTML_Payment_Form" VALUE="<%=headerHTML%>">
  172.                     <INPUT TYPE=HIDDEN NAME="x_Footer_HTML_Payment_Form" VALUE="<%=footerHTML%>">
  173.                     <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Method" VALUE="GET">
  174.                     <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Text" VALUE="Click here to continue">
  175.                     <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_URL" VALUE="<%=host%>/main/customers/purchase.jsp;jsessionid=<%=request.getSession().getId()%>">
  176.                     <INPUT TYPE=SUBMIT NAME=submit_purchase WIDTH="20" VALUE="Purchase">
  177.                              </FORM>
  178.                            </td>
  179.                           </tr>
  180.                      </table>
  181.                    </td></tr>
  182.                   </table>
  183.            </td>
  184.           </tr>
  185.     </table>
  186.  
  187. <!-- FOOTER -->
  188. <jsp:include page="footer.jsp" flush="true"/>
  189.